
package cn.edu.lynu.chapter02;


        import java.util.Scanner;

public class Main {
    static Scanner scanner= new Scanner(System.in);
    static String[] yonghu= new String[]{"张三","李四","王五","马六"};
    static int[]id =new int [] {01,02,03,04};

    static double[] qian = new double []{9999999,54250,55.5,66.6};



    public static void main(String [] args){
        while(true){
            System.out.println("请输入您的账户ID");
            int  idd = scanner.nextInt();

            boolean f=true;
            for (int i=0;i<id.length;i++){
                if(idd==id[i]){



                    System.out.println("欢迎" + yonghu[i] + "您的余额为：" + qian[i]);

                    System.out.println("按1：选择存款；按2：选择取款；按0：选择退出");
                    int xuan = scanner.nextInt();
                    switch (xuan) {
                        case 1:
                            deposit(i);
                            break;

                        case 2:
                            withdraw(i);

                        case 0:
                            break;
                        default:
                            System.out.println("请输入1，2或者0");
                    }
                    f=false;


                }

            }
            if(f){
                System.out.println("您输入的ID不存在，请重新输入");

            }
        }
    }

    private static void withdraw(int i) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("欢迎进入取款界面，请输入您要取出的金额");
        double qu = scanner.nextDouble();

        if(qu<=qian[i]){
            qian[i]-=qu;
            System.out.println("您取出了"+qu+"元，您当前余额为："+qian[i]);
        }else{
            System.out.println("您的余额不足，无法取出");
        }
        System.out.println("输入1继续取款，退出请按0");
        int x=scanner.nextInt();
        switch(x){
            case 1:
                withdraw(i);
                break;

            case 0:
                break;
        }
    }

    private static void deposit(int i) {
        Scanner scanner= new Scanner(System.in);
        System.out.println("欢迎进入存款界面，请输入您要存入的金额");
        double cun=scanner.nextDouble();
        qian [i] += cun;
        System.out.println("您存入了"+cun+"元，您当前余额为："+qian[i]);
        System.out.println("输入1继续存款，退出请按0");
        int x =scanner.nextInt();
        switch (x){
            case 1:
                deposit(i);
                break;

            case 0:
                break;
        }
    }
}


